﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace KalenderTradisional
{
    class Chinese
    {        
        private int hari;
        private int tanggal;
        private int bulan;
        private int tahun;
        private string hariChi;
        private string tanggalChi;
        private string bulanChi;
        private string tahunChi;

        DateTime calendar;

        public Chinese(int tahun,int bulan,int tanggal)
        {
            calendar = new DateTime(tahun,bulan,tanggal);
            this.hari=(int)calendar.DayOfWeek;
            this.tanggal=tanggal;
            this.bulan=bulan;
            this.tahun=tahun;
            setKalender(tahun, bulan, tanggal, (int)calendar.DayOfWeek);
        }

        public void setKalender(int tahun, int bulan, int tanggal, int hari)
        {
            setTanggal(tanggal);
            setHari(hari);
            setBulan(bulan);
            setTahun(tahun);
        }

        public string getHari()
        {
            return this.hariChi;
        }

        public string getTanggal()
        {
            return this.tanggalChi;
        }

        public string getBulan()
        {
            return this.bulanChi;
        }
        
        public string getTahun()
        {
            return this.tahunChi;
        }

        private string angkaChi(int val)
        {
            switch (val)
            {
                case 0: return "〇"; break;
                case 1: return "一"; break;
                case 2: return "二"; break;
                case 3: return "三"; break;
                case 4: return "四"; break;
                case 5: return"五"; break;
                case 6: return "六"; break;
                case 7: return "七"; break;
                case 8: return "八"; break;
                case 9: return "九"; break;
                case 10: return "十"; break;
                case 11: return "十一"; break;
                case 12: return "十二"; break;
                case 13: return "十三"; break;
                case 14: return "十四"; break;
                case 15: return "十五"; break;
                case 16: return "十六"; break;
                case 17: return "十七"; break;
                case 18: return "十八"; break;
                case 19: return "十九"; break;
                case 20: return "二十"; break;
                case 21: return "二十一"; break;
                case 22: return "二十二"; break;
                case 23: return "二十三"; break;
                case 24: return "二十四"; break;
                case 25: return "二十五"; break;
                case 26: return "二十六"; break;
                case 27: return "二十七"; break;
                case 28: return "二十八"; break;
                case 29: return "二十九"; break;
                case 30: return "三十"; break;
                case 31: return "三十一"; break;
                default: return "null"; break;
            }
        
        }
                
        public void setHari(int val)
        {
            this.hari = val;
            switch (val)
            {
                case 0: this.hariChi = "星期天"; break;
                case 1: this.hariChi = "星期一"; break;
                case 2: this.hariChi = "星期二"; break;
                case 3: this.hariChi = "星期三"; break;
                case 4: this.hariChi = "星期四"; break;
                case 5: this.hariChi = "星期五"; break;
                case 6: this.hariChi = "星期六"; break;
                default: this.hariChi = "null"; break;
            }

            //lblHari.Text = getNmHariC(val);
        }

        public void setTanggal(int val)
        {
            this.tanggal = val;
            this.tanggalChi = angkaChi(val);
            //lblTanggal.Text = getTanggalC(val);
        }
        
        public void setBulan(int val)
        {
            this.bulan = val;
            this.bulanChi = angkaChi(val) + "月";
            //lblBulan.Text = getBulanChina(val);
        }

        public void setTahun(int val)
        {
            int a;
            int b;
            int c;
            int d;
            string a2;
            string b2;
            string c2;
            string d2;
            int tamp;
            a = tahun / 1000;
            if (a >= 1)
            {
                a2 = angkaChi(a) + "千";
            }
            else
            {
                a2 = "";
            }
            b = (tahun % 1000) / 100;
            if (b >= 1)
            {
                b2 = angkaChi(b) + "百";
            }
            else
            {
                b2 = "";
            }

            c = ((tahun % 1000) % 100) / 10;
            if (c == 1)
            {
                c2 = "十";
            }
            else if (c > 1)
            {
                c2 = angkaChi(c) + "十";
            }
            else
            {
                c2 = "";
            }

            d = ((tahun % 1000) % 100) % 10;
            if (d >= 1)
            {
                d2 = angkaChi(d);
            }
            else
            {
                d2 = "";
            }

            this.tahun = val;
            this.tahunChi = a2 + b2 + c2 + d2;
            //lblTahun.Text = getTahunChina(tahun);
        }

    }
}
